Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimensional counters #32

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

m-matth
Copy link

@m-matth m-matth commented Nov 19, 2018

PR based on #22, with review taken into account.

Breaking change: the Sample type now holds dimensions as key-value pairs.
@m-matth m-matth force-pushed the dimensional-counters2 branch from 1a16acd to 3ab47b6 Compare November 19, 2018 16:02
@m-matth m-matth force-pushed the dimensional-counters2 branch from 3ab47b6 to 1a77ab4 Compare November 19, 2018 16:18
@23Skidoo 23Skidoo mentioned this pull request Nov 19, 2018
sampleOne (GaugeS m) = Right . Gauge <$> m
sampleOne (LabelS m) = Right . Label <$> m
sampleOne (DistributionS m) = Right . Distribution <$> m
sampleOne (DimensionalS dims m) = Left . (\pairs -> (dims, pairs)) . M.toList <$> m
Copy link
Collaborator

@tibbe tibbe Nov 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to use a strict <$> to force the result to avoid creating thunks. It's quite important that sampling is efficient otherwise we might be slowing down the application with a background task such as monitoring.

readAllRefs m = do
forM ([(name, ref) | (name, Left ref) <- M.toList m]) $ \ (name, ref) -> do
val <- sampleOne ref
return (name, val)
return $ case val of
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want $!.


type Name = Text

type Explanation = Text
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit more of an overall comment but I think all metrics should support an explanation (although I haven't given thought to how to retrofit this into the current API) and each dimension could also use an explanation.

In general I think one might want to attach the following metadata to a metric:

  • It's type e.g. "seconds" or "megabytes". This helps when automatically creating graphs and UIs for metrics.
  • A human-readable explanation of the metrics.
  • An explanation of each dimension.

| not $ matchDimensions (dimensionalDimensions d) pt =
pure $ Left (UnmatchedDimensions err)
| otherwise = do
toLookupResult . HashMap.lookup pt <$> readIORef (dimensionalPoints d)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to force the result.


type Explanation = Text

type Dimensions = [Text]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be convenient to allow a dimension to be a member of some Dimension type class with instances for Text, String, Int, and so forth. Will make the API nicer to use without having to use "to text" conversions at each call site for dimensions that are e.g. naturally ints (e.g. like HTTP status codes). The type class can be used just in the user-facing API. Internally it can all be Text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants